



const imgElements = document.getElementsByTagName("img");
for (let index = 0; index < imgElements.length; index++) {
    const element = imgElements[index];
    element.style.animation = "fade-in 2s";
}

const box = document.getElementById("box-success");
box.style.display = "block";
box.style.animation = "fade-in-top 1s, scale-w-01 2s";
new Typed("#box-success", {
    strings: ["^1500成功的意义应该是发挥了自己的所长，^500尽了自己的努力之后，^500所感到的一种无愧于心的收获之乐，^1000而不是为了虚荣心或金钱。"],
    typeSpeed: 100,
    showCursor: false,
});



HTTP.request({
    method: "get",
    url: "/api/article/page/1"
}).then(response => {
    const result = response.data;
    // console.log(result);

    const template = document.getElementById("list-item-article-template").content.firstElementChild;
    // console.log(template);
    const articleList = document.getElementsByClassName("list-article")[0];
    const articleArray = result.data;
    articleArray.forEach(article => {
        const element = template.cloneNode(true);
        element.getElementsByClassName("box-article-information-date")[0].textContent = article.date;

        const sortElement = element.getElementsByClassName("box-article-information-sort")[0];
        sortElement.href = `/pages/sort.html#${article.sort_name}`;
        sortElement.textContent = article.sort_name;

        /** @type { HTMLElement } */
        const titleElement = element.getElementsByClassName("box-article-information-title")[0]
        // titleElement.innerHTML = article.title; 用打字特效加上去了
        titleElement.href = "/pages/article.html?id=" + article.id;
        articleList.appendChild(element);

        article.title = article.title.replaceAll("<", "&lt;");
        new Typed(titleElement, {
            strings: [article.title],
            typeSpeed: 10,
            showCursor: false,
        });
    });

});


